package com.ruoyi.web.controller.system;

import java.util.List;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.TStudy;
import com.ruoyi.system.service.ITStudyService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学习Controller
 *
 * @author ruoyi
 * @date 2024-03-05
 */
@Controller
@RequestMapping("/system/study")
public class TStudyController extends BaseController {
    private String prefix = "system/study";

    @Autowired
    private ITStudyService tStudyService;

    @RequiresPermissions("system:study:view")
    @GetMapping("/math")
    public String study() {
        return prefix + "/studyMath";
    }

    @RequiresPermissions("system:study:view")
    @GetMapping("/english")
    public String english() {
        return prefix + "/studyEnglish";
    }

    @RequiresPermissions("system:study:view")
    @GetMapping("/chinese")
    public String chinese() {
        return prefix + "/studyChinese";
    }

    @RequiresPermissions("system:study:view")
    @GetMapping("/computer")
    public String computer() {
        return prefix + "/studyComputer";
    }

    @RequiresPermissions("system:study:view")
    @GetMapping("/C")
    public String c() {
        return prefix + "/studyC";
    }

    @RequiresPermissions("system:study:view")
    @GetMapping("/OS")
    public String os() {
        return prefix + "/studyOS";
    }

    @RequiresPermissions("system:study:view")
    @GetMapping("/DS")
    public String ds() {
        return prefix + "/studyDS";
    }

    /**
     * 查询学习列表
     */
    @RequiresPermissions("system:study:list")
    @PostMapping("/listC")
    @Log(title = "数学", businessType = BusinessType.EXPORT)
    @ResponseBody
    public TableDataInfo listC(TStudy tStudy) {
        startPage();
        tStudy.setCourseType(1L);
        List<TStudy> list = tStudyService.selectTStudyList(tStudy);
        return getDataTable(list);
    }

    /**
     * 查询学习列表
     */
    @RequiresPermissions("system:study:list")
    @PostMapping("/listChinese")
    @Log(title = "数学", businessType = BusinessType.EXPORT)
    @ResponseBody
    public TableDataInfo listChinese(TStudy tStudy) {
        startPage();
        tStudy.setCourseType(2L);
        List<TStudy> list = tStudyService.selectTStudyList(tStudy);
        return getDataTable(list);
    }

    /**
     * 查询学习列表
     */
    @RequiresPermissions("system:study:list")
    @PostMapping("/listComputer")
    @Log(title = "数学", businessType = BusinessType.EXPORT)
    @ResponseBody
    public TableDataInfo listComputer(TStudy tStudy) {
        startPage();
        tStudy.setCourseType(3L);
        List<TStudy> list = tStudyService.selectTStudyList(tStudy);
        return getDataTable(list);
    }

    /**
     * 查询学习列表
     */
    @RequiresPermissions("system:study:list")
    @PostMapping("/listDS")
    @Log(title = "数学", businessType = BusinessType.EXPORT)
    @ResponseBody
    public TableDataInfo listDS(TStudy tStudy) {
        startPage();
        tStudy.setCourseType(4L);
        List<TStudy> list = tStudyService.selectTStudyList(tStudy);
        return getDataTable(list);
    }

    /**
     * 查询学习列表
     */
    @RequiresPermissions("system:study:list")
    @PostMapping("/listEnglish")
    @Log(title = "数学", businessType = BusinessType.EXPORT)
    @ResponseBody
    public TableDataInfo listEnglish(TStudy tStudy) {
        startPage();
        tStudy.setCourseType(5L);
        List<TStudy> list = tStudyService.selectTStudyList(tStudy);
        return getDataTable(list);
    }

    /**
     * 查询学习列表
     */
    @RequiresPermissions("system:study:list")
    @PostMapping("/listMath")
    @Log(title = "数学", businessType = BusinessType.EXPORT)
    @ResponseBody
    public TableDataInfo listMath(TStudy tStudy) {
        startPage();
        tStudy.setCourseType(6L);
        List<TStudy> list = tStudyService.selectTStudyList(tStudy);
        return getDataTable(list);
    }

    /**
     * 查询学习列表
     */
    @RequiresPermissions("system:study:list")
    @PostMapping("/listOS")
    @Log(title = "数学", businessType = BusinessType.EXPORT)
    @ResponseBody
    public TableDataInfo listOS(TStudy tStudy) {
        startPage();
        tStudy.setCourseType(7L);
        List<TStudy> list = tStudyService.selectTStudyList(tStudy);
        return getDataTable(list);
    }





    /**
     * 导出学习列表
     */
    @RequiresPermissions("system:study:export")
    @Log(title = "学习", businessType = BusinessType.EXPORT)
    @PostMapping("/exportC")
    @ResponseBody
    public AjaxResult exportC(TStudy tStudy) {
        tStudy.setCourseType(1L);
        List<TStudy> list = tStudyService.selectTStudyList(tStudy);
        ExcelUtil<TStudy> util = new ExcelUtil<TStudy>(TStudy.class);
        return util.exportExcel(list, "学习数据");
    }
    /**
     * 导出学习列表
     */
    @RequiresPermissions("system:study:export")
    @Log(title = "学习", businessType = BusinessType.EXPORT)
    @PostMapping("/exportChinese")
    @ResponseBody
    public AjaxResult exportChinese(TStudy tStudy) {
        tStudy.setCourseType(1L);
        List<TStudy> list = tStudyService.selectTStudyList(tStudy);
        ExcelUtil<TStudy> util = new ExcelUtil<TStudy>(TStudy.class);
        return util.exportExcel(list, "学习数据");
    }    /**
     * 导出学习列表
     */
    @RequiresPermissions("system:study:export")
    @Log(title = "学习", businessType = BusinessType.EXPORT)
    @PostMapping("/exportComputer")
    @ResponseBody
    public AjaxResult exportComputer(TStudy tStudy) {
        tStudy.setCourseType(2L);
        List<TStudy> list = tStudyService.selectTStudyList(tStudy);
        ExcelUtil<TStudy> util = new ExcelUtil<TStudy>(TStudy.class);
        return util.exportExcel(list, "学习数据");
    }    /**
     * 导出学习列表
     */
    @RequiresPermissions("system:study:export")
    @Log(title = "学习", businessType = BusinessType.EXPORT)
    @PostMapping("/exportDS")
    @ResponseBody
    public AjaxResult exportDS(TStudy tStudy) {
        tStudy.setCourseType(3L);
        List<TStudy> list = tStudyService.selectTStudyList(tStudy);
        ExcelUtil<TStudy> util = new ExcelUtil<TStudy>(TStudy.class);
        return util.exportExcel(list, "学习数据");
    }    /**
     * 导出学习列表
     */
    @RequiresPermissions("system:study:export")
    @Log(title = "学习", businessType = BusinessType.EXPORT)
    @PostMapping("/exportEnglish")
    @ResponseBody
    public AjaxResult exportEnglish(TStudy tStudy) {
        tStudy.setCourseType(4L);
        List<TStudy> list = tStudyService.selectTStudyList(tStudy);
        ExcelUtil<TStudy> util = new ExcelUtil<TStudy>(TStudy.class);
        return util.exportExcel(list, "学习数据");
    }    /**
     * 导出学习列表
     */
    @RequiresPermissions("system:study:export")
    @Log(title = "学习", businessType = BusinessType.EXPORT)
    @PostMapping("/exportMath")
    @ResponseBody
    public AjaxResult exportMath(TStudy tStudy) {
        tStudy.setCourseType(5L);
        List<TStudy> list = tStudyService.selectTStudyList(tStudy);
        ExcelUtil<TStudy> util = new ExcelUtil<TStudy>(TStudy.class);
        return util.exportExcel(list, "学习数据");
    }    /**
     * 导出学习列表
     */
    @RequiresPermissions("system:study:export")
    @Log(title = "学习", businessType = BusinessType.EXPORT)
    @PostMapping("/exportOS")
    @ResponseBody
    public AjaxResult exportOS(TStudy tStudy) {
        tStudy.setCourseType(6L);
        List<TStudy> list = tStudyService.selectTStudyList(tStudy);
        ExcelUtil<TStudy> util = new ExcelUtil<TStudy>(TStudy.class);
        return util.exportExcel(list, "学习数据");
    }    /**
     * 导出学习列表
     */
    @RequiresPermissions("system:study:export")
    @Log(title = "学习", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(TStudy tStudy) {
        tStudy.setCourseType(7L);
        List<TStudy> list = tStudyService.selectTStudyList(tStudy);
        ExcelUtil<TStudy> util = new ExcelUtil<TStudy>(TStudy.class);
        return util.exportExcel(list, "学习数据");
    }








    /**
     * 新增学习
     */
    @GetMapping("/addC")
    public String addC() {
        return prefix + "/addC";
    }
    /**
     * 新增学习
     */
    @GetMapping("/addChinese")
    public String addChinese() {
        return prefix + "/addChinese";
    }    /**
     * 新增学习
     */
    @GetMapping("/addComputer")
    public String addComputer() {
        return prefix + "/addComputer";
    }    /**
     * 新增学习
     */
    @GetMapping("/addDS")
    public String addDS() {
        return prefix + "/addDS";
    }    /**
     * 新增学习
     */
    @GetMapping("/addEnglish")
    public String addEnglish() {
        return prefix + "/addEnglish";
    }    /**
     * 新增学习
     */
    @GetMapping("/addMath")
    public String addMath() {
        return prefix + "/addMath";
    }    /**
     * 新增学习
     */
    @GetMapping("/addOS")
    public String addOS() {
        return prefix + "/addOS";
    }
    /**
     * 新增保存学习
     */
    @RequiresPermissions("system:study:add")
    @Log(title = "学习", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(TStudy tStudy) {
        return toAjax(tStudyService.insertTStudy(tStudy));
    }

    /**
     * 修改学习
     */
    @RequiresPermissions("system:study:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap) {
        TStudy tStudy = tStudyService.selectTStudyById(id);
        mmap.put("tStudy", tStudy);
        return prefix + "/edit";
    }

    /**
     * 修改保存学习
     */
    @RequiresPermissions("system:study:edit")
    @Log(title = "学习", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(TStudy tStudy) {
        return toAjax(tStudyService.updateTStudy(tStudy));
    }

    /**
     * 删除学习
     */
    @RequiresPermissions("system:study:remove")
    @Log(title = "学习", businessType = BusinessType.DELETE)
    @PostMapping("/remove")
    @ResponseBody
    public AjaxResult remove(String ids) {
        return toAjax(tStudyService.deleteTStudyByIds(ids));
    }
}
